/*******************************************************************************
 * This file is part of blueprint4j www.blueprint4j.org.
 * 
 *     blueprint4j is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     blueprint4j is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with blueprint4j. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package blueprint4j.db;

import blueprint4j.Constants;

public class FieldGroupAddress extends FieldGroup {
	public final static Type POSTAL=new Type(Constants.ICON_BASE+"actions/mail_post_to.png");
	public final static Type PHYSICAL=new Type(Constants.ICON_BASE+"apps/package.png");
	
	public FieldString street;
	public FieldString suburb; 
	public FieldString city;
	public FieldString province; 
	public FieldString code;
	public FieldStringCountry country;

	public FieldGroupAddress(Type type,String name,String prefix,Entity entity) {
		super(name,type.icon,entity);
		if (prefix==null){
			prefix="";
		}
		if (prefix.length()>0){
			prefix=prefix+"_";
		}
		street = new FieldString(prefix+"street", 0, "Street", 50,entity);
		suburb = new FieldString(prefix+"suburb", 0, "Suburb", 50,entity);
		city = new FieldString(prefix+"city", 0, "City", 50,entity);
		province = new FieldString(prefix+"province", 0, "Province", 50,entity);
		code = new FieldString(prefix+"code", 0, "Code", 10,entity);
		country = new FieldStringCountry(prefix+"country", 0, "Country", entity);
	}
	
	public String toString() {
		return street.get() + ", " + suburb.get() + ", "+ city + "\n" + code + "\n" + province + "\n" + country.get(); 
	}
	
	static class Type{
		String icon;
		Type(String icon){
			this.icon=icon;
		}
	}
}

